package calorie.com.calorie.adapter;

import android.provider.ContactsContract;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import calorie.com.calorie.R;
import calorie.com.calorie.response.NoticeListResponce;


public class NoticeListAdapter extends BaseQuickAdapter<NoticeListResponce.DataBean, BaseViewHolder> {
    public NoticeListAdapter(int layoutResId, @Nullable List<NoticeListResponce.DataBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, NoticeListResponce.DataBean item) {
        TextView textView = helper.getView(R.id.content);
        if (item.getIsMAx() == 1) {
            textView.setVisibility(View.VISIBLE);
        } else {
            textView.setVisibility(View.GONE);
        }

        helper.setText(R.id.tv_notice, item.getTitle()).setText(R.id.content, item.getContent());
        helper.getView(R.id.tv_notice).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                List<NoticeListResponce.DataBean> data = getData();
                for (int w = 0; w < data.size(); w++) {
                    data.get(w).setIsMAx(0);
                }
                item.setIsMAx(1);
                notifyDataSetChanged();

            }
        });
    }
}
